package com.trp.view;

import android.content.Context;

public class PoleView extends GISView {

	private double mWorldX;
	private double mWorldY;

	private float GRAPH_REGION = 5;


	public PoleView(Context context) {
		super(context);
		this.mViewType = GISView.Type.POLE;
	}

	public PoleView(Context context, double x, double y) {
		super(context);
		this.mWorldX = x;
		this.mWorldY = y;
		this.mViewType = GISView.Type.POLE;
	}

	@Override
	protected boolean hitTest(int x, int y) {
		//FIXME transform every time cost performance
		float[] points = { (float) mWorldX, (float) mWorldY };
		Transformation.getInstance().mapWorldPointToScreen(points);
		return points[0]+GRAPH_REGION>x && points[0]-GRAPH_REGION < x && points[1]+GRAPH_REGION > y && points[1]-GRAPH_REGION <y;
	}

	@Override
	protected void notifyLongPress() {
		// TODO
	}

	@Override
	protected void transform() {
		mGraph.reset();
		float[] points = { (float) mWorldX, (float) mWorldY };
		Transformation.getInstance().mapWorldPointToScreen(points);
		mGraph.moveTo(points[0] - GRAPH_REGION, points[1] - GRAPH_REGION);
		mGraph.lineTo(points[0] + GRAPH_REGION, points[1] - GRAPH_REGION);
		mGraph.lineTo(points[0] + GRAPH_REGION, points[1] + GRAPH_REGION);
		mGraph.lineTo(points[0] - GRAPH_REGION, points[1] + GRAPH_REGION);
		mGraph.close();
	}

	@Override
	public void scaleChanged(float scale) {
		GRAPH_REGION *= scale;
	}



}
